package spring.batch.shareDataContext;

import org.springframework.batch.core.StepContribution;
import org.springframework.batch.core.scope.context.ChunkContext;
import org.springframework.batch.core.step.tasklet.Tasklet;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.repeat.RepeatStatus;

/**
 * @Author: huhx
 * @Date: 2017-11-02 下午 8:41
 */
public class GetDataContextTasklet implements Tasklet {
    private String username;

    public void setUsername(String username) {
        this.username = username;
    }

    @Override
    public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
//        ExecutionContext jobExecutionContext = chunkContext.getStepContext().
//                getStepExecution().
//                getJobExecution().
//                getExecutionContext();
//        String username = jobExecutionContext.getString("username");
        System.out.println("username = " + username);
        return RepeatStatus.FINISHED;
    }
}
